#include <iostream>
using namespace std;
int result[101][101];
void output(int k);
int main()
{
	int n;
	while(cin>>n){
		output(n);
	}
	return 0;
}

void output(int k)
{
	int num=1;
	for(int i=0;i<k;i++){
		result[i][k-1]=num;
		num++;
	} 
	int i,j;
	i=k-1;
	j=k-1;
	int dir=1;
	int jishuqi=2;
	int cishu=k-1;
	int x,y;
	while(num<=k*k){
		switch(dir){
		case 1:
			y=j-1;
			for(int h=0;h<cishu;h++){
				result[i][y]=num;
				num++;
				y--;
				
			}
			jishuqi--;
			if(jishuqi==0){
				cishu--;
				jishuqi=2;
			}
			j=y+1;
			dir=2;
			break;
		case 2:
			x=i-1;
			for(int h=0;h<cishu;h++){
				result[x][j]=num;
				num++;
				x--;
				
			}
			jishuqi--;
			if(jishuqi==0){
				cishu--;
				jishuqi=2;
			}
			i=x+1;
			dir=3;
			break;
		case 3:
			 y=j+1;
			for(int h=0;h<cishu;h++){
				result[i][y]=num;
				num++;
				y++;
				
			}
			jishuqi--;
			if(jishuqi==0){
				cishu--;
				jishuqi=2;
			}
			j=y-1;
			dir=4;
			break;
		case 4:
			 x=i+1;
			for(int h=0;h<cishu;h++){
				result[x][j]=num;
				num++;
				x++;
				
			}
			jishuqi--;
			if(jishuqi==0){
				cishu--;
				jishuqi=2;
			}
			i=x-1;
			dir=1;
			break;	
	}
	}
	for(int f=0;f<k;f++){
		for(int ff=0;ff<k;ff++){
			cout<<result[f][ff]<<" ";
		}
		cout<<endl;
	}
}
